home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTChunk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  3.5 KB  |  161 lines

  1. /*                                                HTChunk: Flexible array handling for libwww
  2.                                      CHUNK HANDLING:
  3.                                      FLEXIBLE ARRAYS
  4.                                              
  5.    This module implements a flexible array. It is a general utility module. A chunk is a
  6.    structure which may be extended.  These routines create and append data to chunks,
  7.    automatically reallocating them as necessary.
  8.    
  9.  */
  10. typedef struct {
  11.         int     size;           /* In bytes                     */
  12.         int     growby;         /* Allocation unit in bytes     */
  13.         int     allocated;      /* Current size of *data        */
  14.         char *  data;           /* Pointer to malloced area or 0 */
  15. } HTChunk;
  16.  
  17.  
  18. #ifdef SHORT_NAMES
  19. #define HTChunkClear            HTChClea
  20. #define HTChunkPutc             HTChPutc
  21. #define HTChunkPuts             HTChPuts
  22. #define HTChunkCreate           HTChCrea
  23. #define HTChunkTerminate        HTChTerm
  24. #define HTChunkEnsure           HtChEnsu
  25. #endif
  26.  
  27.  
  28. /*
  29.  
  30. Create new chunk
  31.  
  32.   ON ENTRY,
  33.   
  34.   growby                  The number of bytes to allocate at a time when the chunk is
  35.                          later extended. Arbitrary but normally a trade-off time vs.
  36.                          memory
  37.                          
  38.   ON EXIT,
  39.   
  40.   returns                 A chunk pointer to the new chunk,
  41.                          
  42.  */
  43.  
  44. extern HTChunk * HTChunkCreate PARAMS((int growby));
  45.  
  46.  
  47. /*
  48.  
  49. Free a chunk
  50.  
  51.   ON ENTRY,
  52.   
  53.   ch                      A valid chunk pointer made by HTChunkCreate()
  54.                          
  55.   ON EXIT,
  56.   
  57.   ch                      is invalid and may not be used.
  58.                          
  59.  */
  60.  
  61. extern void HTChunkFree PARAMS((HTChunk * ch));
  62.  
  63.  
  64. /*
  65.  
  66. Clear a chunk
  67.  
  68.   ON ENTRY,
  69.   
  70.   ch                      A valid chunk pointer made by HTChunkCreate()
  71.                          
  72.   ON EXIT,
  73.   
  74.   *ch                     The size of the chunk is zero.
  75.                          
  76.  */
  77.  
  78. extern void HTChunkClear PARAMS((HTChunk * ch));
  79.  
  80.  
  81. /*
  82.  
  83. Ensure a chunk has a certain space in
  84.  
  85.   ON ENTRY,
  86.   
  87.   ch                      A valid chunk pointer made by HTChunkCreate()
  88.                          
  89.   s                       The size required
  90.                          
  91.   ON EXIT,
  92.   
  93.   *ch                     Has size at least s
  94.                          
  95.  */
  96.  
  97. extern void HTChunkEnsure PARAMS((HTChunk * ch, int s));
  98.  
  99.  
  100. /*
  101.  
  102. Append a character to a  chunk
  103.  
  104.   ON ENTRY,
  105.   
  106.   ch                      A valid chunk pointer made by HTChunkCreate()
  107.                          
  108.   c                       The character to be appended
  109.                          
  110.   ON EXIT,
  111.   
  112.   *ch                     Is one character bigger
  113.                          
  114.  */
  115. extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
  116.  
  117. /*
  118.  
  119. Append a string to a  chunk
  120.  
  121.   ON ENTRY,
  122.   
  123.   ch                      A valid chunk pointer made by HTChunkCreate()
  124.                          
  125.   str                     Tpoints to a zero-terminated string to be appended
  126.                          
  127.   ON EXIT,
  128.   
  129.   *ch                     Is bigger by strlen(str)
  130.                          
  131.  */
  132.  
  133.  
  134. extern void HTChunkPuts PARAMS((HTChunk * ch, const char *str));
  135.  
  136.  
  137. /*
  138.  
  139. Append a zero character to a  chunk
  140.  
  141.  */
  142.  
  143. /*
  144.  
  145.   ON ENTRY,
  146.   
  147.   ch                      A valid chunk pointer made by HTChunkCreate()
  148.                          
  149.   ON EXIT,
  150.   
  151.   *ch                     Is one character bigger
  152.                          
  153.  */
  154.  
  155.  
  156. extern void HTChunkTerminate PARAMS((HTChunk * ch));
  157.  
  158. /*
  159.  
  160.    end */
  161.